//
//  U9FindManager.m
//  U9WatchGame
//
//  Created by uuu9 on 2017/4/19.
//  Copyright © 2017年 Jason. All rights reserved.
//

#import "U9FindManager.h"
#import "U9FindSettingModel.h"
#import "U9FaithModel.h"
#import "U9LOLPlayerListModel.h"
#import "U9LOLPlayerDetailModel.h"
#import "U9LOLBattleDetailModel.h"


@implementation U9FindManager

+ (void)getFindSettingWithCompletionHandle:(void (^) (U9FindSettingModel *model, NSError *error))complete{
    [self POST:[NSString stringWithFormat:@"%@%@",Api_URL,kFindSetting]
    parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    U9FindSettingModel *model = [U9FindSettingModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model,error);
}];
}


#pragma mark 获取LOL队员排行榜
+ (void)getLOLPlayerListWithCompletionHandle:(void (^)(U9LOLPlayerListModel *model, NSError *))complete{
        [self POST:[NSString stringWithFormat:@"%@%@",Player_URL,kLOLPlayerList]
        parameters:nil
    completionHandler:^(id responseObj, NSError *error) {
        U9LOLPlayerListModel *model = [U9LOLPlayerListModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model, error);
    }];
}


#pragma mark 获取LOL队员详情
+ (void)getLOLPlayerDetailWithPlayerID:(NSString *)playerID andCompletionHandle:(void (^)(U9LOLPlayerDetailModel *model, NSError *))complete{
    [self POST:[NSString stringWithFormat:@"%@/pl/%@/game/list",Player_URL,playerID]
    parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    U9LOLPlayerDetailModel *model = [U9LOLPlayerDetailModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model, error);
}];
}

#pragma mark 获取LOL队员比赛列表
+ (void)getLOLPlayerBattleDetailWithPlayerID:(NSString *)playerID andGameID:(NSString *)gameID andCompletionHandle:(void (^)(U9LOLBattleDetailModel *model, NSError *))complete{
    [self POST:[NSString stringWithFormat:@"%@/pl/%@/game/detail/%@",Player_URL,playerID,gameID]
    parameters:nil
completionHandler:^(id responseObj, NSError *error) {
    U9LOLBattleDetailModel *model = [U9LOLBattleDetailModel mj_objectWithKeyValues:responseObj];
    if (model.error_code != 0) {
        error = [self createError:model.error_msg];
    }
    complete(model, error);
}];
}
/*
 #pragma mark 获取热门战队
 - (void)getHotTeam:(NSString *)gid andBlock:(RequestFinishBlock)block{
 [self.manager GET:[NSString stringWithFormat:@"%@%@",Api_URL,kGetHotTeam]
 parameters:@{@"gid":gid}
 progress:nil
 success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
 @try {
 id dict = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
 if ([dict[@"error_code"] longLongValue] == 0) {
 [_plist storageToPlist:dict andFileName:@"HotTeam"];
 } else {
 dict = [_plist readFromPlist:@"HotTeam"];
 }
 if (block) {
 block(dict);
 }
 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"isOnline"];
 }
 @finally {
 
 }
 }
 failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
 [[NSUserDefaults standardUserDefaults] setBool:false forKey:@"isOnline"];
 NSMutableDictionary *dict = [_plist readFromPlist:@"HotTeam"];
 if (block) {
 block(dict);
 }
 }];
 }
 
 */

@end
